package com.tamecode.chapter05.part10;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * 输出结果：
 *    construct...
 *    execute in setCar
 *    execute in init1
 *    execute in init2
 *    execute in destroy1
 *    execute in destroy2
 */
@Component
public class Boss {

    private Car car;

    public Boss() {
        System.out.println("construct...");
    }

    @Autowired
    public void setCar(Car car) {
        System.out.println("execute in setCar");
        this.car = car;
    }

    @PostConstruct
    public void init1(){
        System.out.println("execute in init1");
    }

    @PostConstruct
    public void init2(){
        System.out.println("execute in init2");
    }

    @PreDestroy
    public void destroy1(){
        System.out.println("execute in destroy1");
    }

    @PreDestroy
    public void destroy2(){
        System.out.println("execute in destroy2");
    }

}
